Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to display the first position of the element "Apple", starting the search at position 4:</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var fruits = ["Banana", "Orange", "Apple", "Mango", "Banana", "Orange", "Apple", "Mango"]; var a = fruits.indexOf("Apple", 4); document.getElementById("demo").innerHTML = a; } </script> <p><b>Note:</b> The indexOf method was introduced in JavaScript 1.6, and does not work in Internet Explorer 8 and earlier versions.</p> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_indexof_array2 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:27:18 GMT --> </html>
Result:
Try it Yourself - © w3schools.com